﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Microserve.TeleEye.BusinessServices;

using MenuBar = Microserve.TeleEye.Common.MenuBar;
using Microserve.TeleEye.Common.Products;

namespace Microserve.TeleEye.Web
{
    public partial class ProductGroup : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            string sectionname = Request.QueryString["p"];

            MenuController controller = new MenuController();
            List<MenuBar.MenuItem> items = controller.GetSectionMenu(HttpContext.Current,
                sectionname);

            items.AddRange(controller.GetSectionMenu(HttpContext.Current,
                "commonmenu"));

            this.toolboxlist.Controls.Add(new LiteralControl()
            {
                Text =
                    Utility.MenuFactory.GenerateMenu(items)
            });
            
            FeaturedProductManager fpManager = new FeaturedProductManager();
            List<Microserve.TeleEye.Common.Products.Product> fProducts = fpManager.GetProductList(HttpContext.Current,
                sectionname);

            this.productlist.DataSource = fProducts;
            this.productlist.DataBind();
           
            SectionManager sManager = new SectionManager();
            this.sectionTitle.InnerHtml = sManager.GetSectionTitle(HttpContext.Current, sectionname);
            this.rightTitle.InnerHtml = sManager.GetSectionSubtitle(HttpContext.Current, sectionname);
            this.sectionAbstract.InnerHtml = sManager.GetSectionAbstract(HttpContext.Current, sectionname);

            string parentSectionText = sManager.GetSectionParentText(HttpContext.Current, sectionname);
            string parentSectionUrl = sManager.GetSectionParentUrl(HttpContext.Current, sectionname);
            string currentSectionText = sManager.GetSectionName(HttpContext.Current, sectionname);
            if (parentSectionText != null)
            {
                this.parentsection.InnerHtml = parentSectionText;
                this.parentsection.HRef = parentSectionUrl;
                this.lblCurrentSection.Text = " > " + currentSectionText;

                ((Main)this.Master).PageSpecificTitle = currentSectionText;
            }
        }
    }
}
